﻿using System;
using System.Linq;
using AutoMapper;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Portal.Repository.Bootstraper;

namespace Portal.Presentation.Tests.Units
{
	[TestClass]
	public class Initialization
	{
		[AssemblyInitialize()]
		public static void GlobalTestInitialize(TestContext testContext)
		{
			Mapper.Initialize(x => GetConfiguration(Mapper.Configuration));
		}

		private static void GetConfiguration(IConfiguration configuration)
		{
            var profiles = typeof(PresentationAutoMapper).Assembly.GetTypes().Where(x => typeof(Profile).IsAssignableFrom(x));
			foreach (var profile in profiles)
			{
				configuration.AddProfile(Activator.CreateInstance(profile) as Profile);
			}
		}
	}
}